import Taro from '@tarojs/taro-rn';
import * as tslib_1 from "tslib";
import React from 'react';
import { Component } from "@tarojs/taro-rn";
import { View, Image, Text } from "@tarojs/components-rn";
import { toJS } from 'mobx';
import { inject, observer } from "@tarojs/mobx-rn";
import { getRuntime } from "../../utils/common";
import order_pay_successStyleSheet from "./order_pay_success_styles";
import success_icon from '../../assets/img/icon_29.png';
import address from "../../assets/img/icon_59.png";
var _styleSheet = order_pay_successStyleSheet;
let OrderPaySuccess = class OrderPaySuccess extends Component {
  constructor(props) {
    super(props);
    this.state = {
      orderInfo: {}
    };
  }
  componentWillMount() {
    Taro.setNavigationBarTitle({ title: '订单支付成功' });
    let id = this.$router.params.id;
    if (!id) {
      getRuntime().navigateBack();
      return;
    }
    this.getOrder(Number.parseInt(id));
  }
  getOrder(id) {
    let { PointMallStore } = this.props.stores;
    PointMallStore.getOrder({
      formId: id,
      callback: res => {
        this.setState({
          orderInfo: toJS(res)
        });
      }
    });
  }
  handelRouter(url = '/pages/index/index') {
    getRuntime().navigateTo(url);
  }
  render() {
    let { orderInfo } = this.state;
    return <View style={_styleSheet["pay-success"]}>
        <View style={_styleSheet["apply-success"]}>
          <View style={_styleSheet["content"]}>
            <Image src={success_icon} style={_styleSheet["success-icon"]} />
            <View style={_styleSheet["title"]}>订单支付成功</View>
            <View style={[_styleSheet["pay-desc"], _styleSheet["color"]]}>请等待商家为你发货</View>
          </View>

          <View style={_styleSheet["interval"]} />
          <View style={_styleSheet["has-address"]}>
            <Image src={address} style={_styleSheet["address-icon"]} />
            <View style={_styleSheet["info"]}>
              <View style={_styleSheet["name"]}>{orderInfo.receiver}  {orderInfo.receiverPhone}</View>
              <View style={_styleSheet["address"]}> {orderInfo.receiverAddress}</View>
            </View>
          </View>
          <View style={_styleSheet["interval"]} />

          <View style={_styleSheet["has-address"]}>
            <View style={_styleSheet["title"]}>实付金额</View>
            <View style={[_styleSheet["all-price"], _styleSheet["color"]]}>
              <Text style={_styleSheet["list-small"]}>￥</Text>
              <Text>{orderInfo.actualAmount}</Text>
            </View>
          </View>

          <View style={_styleSheet["btn-group"]}>
            <View onClick={this.handelRouter.bind(this, '/pages/user/order_detail?id=' + orderInfo.id)} style={[_styleSheet["btn"], _styleSheet["btn-active"]]}>订单详情</View>
            <View onClick={this.handelRouter.bind(this, '/pages/user/order')} style={_styleSheet["btn"]}>我的订单</View>
          </View>
        </View>
      </View>;
  }
};
OrderPaySuccess = tslib_1.__decorate([inject("stores"), observer], OrderPaySuccess);
export default OrderPaySuccess;